package com.microsoft;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.model.Data;
import com.service.*;

/**
 * Created by sww on 16-5-5.
 */

//后期优化方向：通过组合查询减少查询的次数
public class GetHop {
    //type: Id-Id, Id-AuId, AuId-Id, AuId-AuId

    //type: Id-Id
    public static JSONArray getHop(Data data1, Data data2){ //这里还返回hop3中的Id,Id,Id,Id结果
        Request request = new Request();
        JSONArray result = new JSONArray();

        for(int i = 0; i < data1.RId.size(); i++){
            if((long)data1.RId.get(i) == data2.Id.get(0)){  //data2是data1的引用文献
                long[] hop_1 = new long[2];
                hop_1[0] = data1.Id.get(0);
                hop_1[1] = data2.Id.get(0);
                System.out.print(hop_1[0]+","+ hop_1[1]+"\n");
                result.add(hop_1);
                break;
            }
        }


        //若边为FId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_F = data1.FId.toArray();
        Object[] data2_F = data2.FId.toArray();
        for(int i=0;i<data1_F.length;i++){
            for(int j=0;j<data2_F.length;j++){
                if(Long.valueOf(String.valueOf(data1_F[i])).longValue() == Long.valueOf(String.valueOf(data2_F[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_F[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("FId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }
        //若边为CId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_C = data1.CId.toArray();
        Object[] data2_C = data2.CId.toArray();
        for(int i=0;i<data1_C.length;i++){
            for(int j=0;j<data2_C.length;j++){
                if(Long.valueOf(String.valueOf(data1_C[i])).longValue() == Long.valueOf(String.valueOf(data2_C[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_C[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("CId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }
        //若边为JId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_J = data1.JId.toArray();
        Object[] data2_J = data2.JId.toArray();
        for(int i=0;i<data1_J.length;i++){
            for(int j=0;j<data2_J.length;j++){
                if(Long.valueOf(String.valueOf(data1_J[i])).longValue() == Long.valueOf(String.valueOf(data2_J[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_J[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("JId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }
        //若边为AuId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_Au = data1.AuId.toArray();
        Object[] data2_Au = data2.AuId.toArray();
        for(int i=0;i<data1_Au.length;i++){
            for(int j=0;j<data2_Au.length;j++){
                //Object t1=data1_Au[i];
                //Object t2=data2_Au[j];
                if(Long.valueOf(String.valueOf(data1_Au[i])).longValue() == Long.valueOf(String.valueOf(data2_Au[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_Au[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("AuId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }

        Data data_t1,data_t2;
        Object[] data1_R=data1.RId.toArray();
        /*//若边为RID
        //下方为通过查询以data_2为RId的Id，比较与data_t1的RId的区别。
        // !!!!!这里还可以使用组合查询，查找年份小于等于data_t1的Id!!!!!
        List<Data> data2_bRId_list = request.request(data2.Id.get(0),"RId",1); //获取以data2为RId的Id,这边需要修改成使用组合查询
        for(int i = 0; i < data2_bRId_list.size(); i++){
            for(int j = 0; j < data1_R.length; j++){
                if((long)data2_bRId_list.get(i).Id.get(0) == Long.valueOf(String.valueOf(data1_R[i])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = data2_bRId_list.get(i).Id.get(0);
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("RId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }
        */


        for(int i = 0; i < data1_R.length; i++){
            //将RID的request结果存储到data_t中，下方为前向查询，查data1的RId的RId是否含有data2
            //查看对应ID的RID若有，则返回结果，否则，继续循环
            data_t1 = request.request(Long.valueOf(String.valueOf(data1_R[i])).longValue(),"Id");
            //RID
            for(int j = 0; j < data_t1.RId.size(); j++){
                if((long)data_t1.RId.get(j) == data2.Id.get(0)){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = data_t1.Id.get(0);
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("RId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }

            //获取hop3结果，在这一段，还需要添加判别hop3[1]!=hop3[2]的函数
            //两条边均为RId
            Object[] data_t1_R = data_t1.RId.toArray();
            for(int j = 0; j < data_t1_R.length; j++){
                data_t2 = request.request(Long.valueOf(String.valueOf(data_t1_R[j])).longValue(),"Id");  //第i个引用文献的第j个引用文献的id
                for(int k = 0; k < data_t2.RId.size(); k++){
                    if((long)data_t2.RId.get(k) == data2.Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data_t1.Id.get(0);
                        hop_3[2] = Long.valueOf(String.valueOf(data_t1_R[j])).longValue();
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }

            }

            //一条边为RId，另一条边为FId
            Object[] data_t1_F = data_t1.FId.toArray();  //data1的第i个引用文献的所有fid
            //Object[] data2_F = data2.FId.toArray(); //data2的所有fid
            for(int j = 0; j < data_t1_F.length; j++){
                for(int k = 0; k < data2_F.length; k++){
                    if(Long.valueOf(String.valueOf(data_t1_F[j])).longValue() == Long.valueOf(String.valueOf(data2_F[k])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data_t1.Id.get(0);
                        hop_3[2] = Long.valueOf(String.valueOf(data_t1_F[j])).longValue();
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("RId-FId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //一条边为RId，另一条边为CId
            Object[] data_t1_C = data_t1.CId.toArray();  //data1的第i个引用文献的所有fid
            //Object[] data2_C = data2.CId.toArray(); //data2的所有fid
            for(int j = 0; j < data_t1_C.length; j++){
                for(int k = 0; k < data2_C.length; k++){
                    if(Long.valueOf(String.valueOf(data_t1_C[j])).longValue() == Long.valueOf(String.valueOf(data2_C[k])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data_t1.Id.get(0);
                        hop_3[2] = Long.valueOf(String.valueOf(data_t1_C[j])).longValue();
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("RId-CId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //一条边为RId，另一条边为JId
            Object[] data_t1_J = data_t1.JId.toArray();  //data1的第i个引用文献的所有fid
            //Object[] data2_J = data2.JId.toArray(); //data2的所有fid
            for(int j = 0; j < data_t1_J.length; j++){
                for(int k = 0; k < data2_J.length; k++){
                    if(Long.valueOf(String.valueOf(data_t1_J[j])).longValue() == Long.valueOf(String.valueOf(data2_J[k])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data_t1.Id.get(0);
                        hop_3[2] = Long.valueOf(String.valueOf(data_t1_J[j])).longValue();
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("RId-JId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //一条边为RId，另一条边为AuId
            Object[] data_t1_Au = data_t1.AuId.toArray();  //data1的第i个引用文献的所有fid
            //Object[] data2_Au = data2.AuId.toArray(); //data2的所有fid
            for(int j = 0; j < data_t1_Au.length; j++){
                for(int k = 0; k < data2_Au.length; k++){
                    if(Long.valueOf(String.valueOf(data_t1_Au[j])).longValue() == Long.valueOf(String.valueOf(data2_Au[k])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data_t1.Id.get(0);
                        hop_3[2] = Long.valueOf(String.valueOf(data_t1_Au[j])).longValue();
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("RId-AuId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }

        //一条边为AuId,一条边为RId
        //Object[] data1_Au=data1.AuId.toArray();   //data_1的所有Fid取值
        for(int i = 0; i< data1_Au.length; i++){
            List<Data> data1_Au_list = new ArrayList<Data>();
            data1_Au_list = request.request(Long.valueOf(String.valueOf(data1_Au[i])).longValue(),"AA.AuId",1); //返回所有与AuId相同的Datalist
            for(int j = 0; j<data1_Au_list.size();j++){
                data_t1 = data1_Au_list.get(j);
                for(int k = 0; k < data_t1.RId.size(); k++){
                    if(data_t1.RId.get(k) == data2.Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data1.AuId.get(i);
                        hop_3[2] = data_t1.Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("AuId-RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }
        //一条边为CId,一条边为RId，
        //Object[] data1_C=data1.CId.toArray();   //data_1的所有Fid取值
        for(int i = 0; i< data1_C.length; i++){
            List<Data> data1_C_list = new ArrayList<Data>();
            data1_C_list = request.request(Long.valueOf(String.valueOf(data1_C[i])).longValue(),"C.CId",1); //返回所有与AuId相同的Datalist
            for(int j = 0; j<data1_C_list.size();j++){
                data_t1 = data1_C_list.get(j);
                for(int k = 0; k < data_t1.RId.size(); k++){
                    if(data_t1.RId.get(k) == data2.Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data1.CId.get(i);
                        hop_3[2] = data_t1.Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("CId-RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }
        //一条边为JId,一条边为RId,由于最大返回数目为40，可能有些结果不能返回
        //Object[] data1_J=data1.JId.toArray();   //data_1的所有Fid取值
        for(int i = 0; i< data1_J.length; i++){
            List<Data> data1_J_list = new ArrayList<Data>();
            data1_J_list = request.request(Long.valueOf(String.valueOf(data1_J[i])).longValue(),"J.JId",1); //返回所有与AuId相同的Datalist
            for(int j = 0; j<data1_J_list.size();j++){
                data_t1 = data1_J_list.get(j);
                for(int k = 0; k < data_t1.RId.size(); k++){
                    if(data_t1.RId.get(k) == data2.Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data1.JId.get(i);
                        hop_3[2] = data_t1.Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("JId-RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }
        //一条边为FId,一条边为RId
        //Object[] data1_F=data1.FId.toArray();   //data_1的所有Fid取值
        for(int i = 0; i< data1_F.length; i++){
            List<Data> data1_F_list;
            data1_F_list = request.request(Long.valueOf(String.valueOf(data1_F[i])).longValue(),"F.FId",1); //返回所有与AuId相同的Datalist
            for(int j = 0; j<data1_F_list.size();j++){
                data_t1 = data1_F_list.get(j);
                for(int k = 0; k < data_t1.RId.size(); k++){
                    if(data_t1.RId.get(k) == data2.Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data1.FId.get(i);
                        hop_3[2] = data_t1.Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("FId-RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }

        /////
        return result;
    }

    //type: Id-Id    fast_改进算法
    public static JSONArray getHop_f(Data data1, Data data2){ //这里还返回hop3中的Id,Id,Id,Id结果
        Request request = new Request();
        JSONArray result = new JSONArray();

        for(int i = 0; i < data1.RId.size(); i++){
            if((long)data1.RId.get(i) == data2.Id.get(0)){  //data2是data1的引用文献
                long[] hop_1 = new long[2];
                hop_1[0] = data1.Id.get(0);
                hop_1[1] = data2.Id.get(0);
                System.out.print(hop_1[0]+","+ hop_1[1]+"\n"); // Id - Id
                result.add(hop_1);
                break;
            }
        }


        //若边为FId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_F = data1.FId.toArray();
        Object[] data2_F = data2.FId.toArray();
        for(int i=0;i<data1_F.length;i++){
            for(int j=0;j<data2_F.length;j++){
                if(Long.valueOf(String.valueOf(data1_F[i])).longValue() == Long.valueOf(String.valueOf(data2_F[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_F[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("FId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");  //Id - FId - Id
                    result.add(hop_2);
                    break;
                }
            }
        }
        //若边为CId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_C = data1.CId.toArray();
        Object[] data2_C = data2.CId.toArray();
        for(int i=0;i<data1_C.length;i++){
            for(int j=0;j<data2_C.length;j++){
                if(Long.valueOf(String.valueOf(data1_C[i])).longValue() == Long.valueOf(String.valueOf(data2_C[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_C[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("CId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");  //Id - CId - Id
                    result.add(hop_2);
                    break;
                }
            }
        }
        //若边为JId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_J = data1.JId.toArray();
        Object[] data2_J = data2.JId.toArray();
        for(int i=0;i<data1_J.length;i++){
            for(int j=0;j<data2_J.length;j++){
                if(Long.valueOf(String.valueOf(data1_J[i])).longValue() == Long.valueOf(String.valueOf(data2_J[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_J[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("JId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");  //Id - JId - Id
                    result.add(hop_2);
                    break;
                }
            }
        }
        //若边为AuId,则需要判断data1和data2中fid的重合的id，并存储，遍历求交集
        Object[] data1_Au = data1.AuId.toArray();
        Object[] data2_Au = data2.AuId.toArray();
        for(int i=0;i<data1_Au.length;i++){
            for(int j=0;j<data2_Au.length;j++){
                //Object t1=data1_Au[i];
                //Object t2=data2_Au[j];
                if(Long.valueOf(String.valueOf(data1_Au[i])).longValue() == Long.valueOf(String.valueOf(data2_Au[j])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = Long.valueOf(String.valueOf(data1_Au[i])).longValue();
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("AuId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");  //Id - AuId - Id
                    result.add(hop_2);
                    break;
                }
            }
        }

        Data data_t1;
        Object[] data1_R=data1.RId.toArray();

        //fast
        //若边为RID
        //下方为通过查询以data_2为RId的Id，比较与data_t1的RId的区别。
        // !!!!!这里还可以使用组合查询，查找年份小于等于data_t1的Id!!!!!
        List<Data> data2_bRId_list = request.request(data2.Id.get(0),"RId",1); //获取以data2为RId的Id,这边需要修改成使用组合查询
        for(int i = 0; i < data2_bRId_list.size(); i++){
            for(int j = 0; j < data1_R.length; j++){
                if((long)data2_bRId_list.get(i).Id.get(0) == Long.valueOf(String.valueOf(data1_R[i])).longValue()){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = data2_bRId_list.get(i).Id.get(0);
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("RId: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
            //3-hop
            //Au_Id
            for(int j = 0; j < data1_Au.length; j++){
                for(int k = 0; k < data2_bRId_list.get(i).AuId.size(); k++){
                    if((long)data2_bRId_list.get(i).AuId.get(k) == Long.valueOf(String.valueOf(data1_Au[i])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data2_bRId_list.get(i).AuId.get(k);
                        hop_3[2] = data2_bRId_list.get(i).Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id-AuId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //C_Id
            for(int j = 0; j < data1_C.length; j++){
                for(int k = 0; k < data2_bRId_list.get(i).CId.size(); k++){
                    if((long)data2_bRId_list.get(i).CId.get(k) == Long.valueOf(String.valueOf(data1_C[i])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data2_bRId_list.get(i).CId.get(k);
                        hop_3[2] = data2_bRId_list.get(i).Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id-CId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //J_Id
            for(int j = 0; j < data1_J.length; j++){
                for(int k = 0; k < data2_bRId_list.get(i).JId.size(); k++){
                    if((long)data2_bRId_list.get(i).JId.get(k) == Long.valueOf(String.valueOf(data1_J[i])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data2_bRId_list.get(i).JId.get(k);
                        hop_3[2] = data2_bRId_list.get(i).Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id-JId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //F_Id
            for(int j = 0; j < data1_F.length; j++){
                for(int k = 0; k < data2_bRId_list.get(i).FId.size(); k++){
                    if((long)data2_bRId_list.get(i).FId.get(k) == Long.valueOf(String.valueOf(data1_F[i])).longValue()){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data2_bRId_list.get(i).FId.get(k);
                        hop_3[2] = data2_bRId_list.get(i).Id.get(0);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id-FId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }

        //判断请求次数来选择使用什么方法获取 Id_FId, Id_CId, Id_JId, Id_AuId 的hop
        int request_1_num = data1.RId.size();
        int request_2_num = data2.FId.size() + data2.CId.size() + data2.AuId.size() + data2.JId.size();
        if(request_1_num > request_2_num){ //使用后向请求
            //边为 Id-FId
            for(int i = 0; i < data2.FId.size(); i++){
                List<Data> data2_bFId_list = request.request(data2.FId.get(i),"F.FId",1); //获取以data2为FId的Id,这边需要修改成使用组合查询
                for(int k = 0; k < data2_bFId_list.size(); k++){
                    for(int l = 0; l < data1_R.length; l++){
                        if(data2_bFId_list.get(k).Id.get(0) == Long.valueOf(String.valueOf(data1_R[l])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data2_bFId_list.get(k).Id.get(0);
                            hop_3[2] = data2.FId.get(i);
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("Id-FId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
            }
            //边为 Id-CId
            for(int i = 0; i < data2.CId.size(); i++){
                List<Data> data2_bCId_list = request.request(data2.CId.get(i),"C.CId",1); //获取以data2为FId的Id,这边需要修改成使用组合查询
                for(int k = 0; k < data2_bCId_list.size(); k++){
                    for(int l = 0; l < data1_R.length; l++){
                        if(data2_bCId_list.get(k).Id.get(0) == Long.valueOf(String.valueOf(data1_R[l])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data2_bCId_list.get(k).Id.get(0);
                            hop_3[2] = data2.CId.get(i);
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("Id-CId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
            }
            //边为 Id-JId
            for(int i = 0; i < data2.JId.size(); i++){
                List<Data> data2_bJId_list = request.request(data2.JId.get(i),"J.JId",1); //获取以data2为FId的Id,这边需要修改成使用组合查询
                for(int k = 0; k < data2_bJId_list.size(); k++){
                    for(int l = 0; l < data1_R.length; l++){
                        if(data2_bJId_list.get(k).Id.get(0) == Long.valueOf(String.valueOf(data1_R[l])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data2_bJId_list.get(k).Id.get(0);
                            hop_3[2] = data2.JId.get(i);
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("Id-JId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
            }
            //边为 Id-AuId
            for(int i = 0; i < data2.AuId.size(); i++){
                List<Data> data2_bAuId_list = request.request(data2.AuId.get(i),"J.JId",1); //获取以data2为FId的Id,这边需要修改成使用组合查询
                for(int k = 0; k < data2_bAuId_list.size(); k++){
                    for(int l = 0; l < data1_R.length; l++){
                        if(data2_bAuId_list.get(k).Id.get(0) == Long.valueOf(String.valueOf(data1_R[l])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data2_bAuId_list.get(k).Id.get(0);
                            hop_3[2] = data2.AuId.get(i);
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("Id-AuId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
            }
            //3-hop, Id,Id,Id,Id
            for(int i = 0; i < data1_R.length; i++){
                data_t1 = request.request(Long.valueOf(String.valueOf(data1_R[i])).longValue(),"Id");
                for(int j = 0; j < data_t1.RId.size(); j++){
                    for(int k = 0; k < data2_bRId_list.size(); k++){
                        if(data_t1.RId.get(j) == data2_bRId_list.get(k).Id.get(0)){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = data_t1.RId.get(j);
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("Id-FId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
            }
        }else { //使用前向遍历方法
            for(int i = 0; i < data1_R.length; i++){
                data_t1 = request.request(Long.valueOf(String.valueOf(data1_R[i])).longValue(),"Id");
                //3-hop, Id,Id,Id,Id
                for(int j = 0; j < data_t1.RId.size(); j++){
                    for(int k = 0; k < data2_bRId_list.size(); k++){
                        if(data_t1.RId.get(j) == data2_bRId_list.get(k).Id.get(0)){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = data_t1.RId.get(j);
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("Id-FId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
                //边为 Id-FId
                Object[] data_t1_F = data_t1.FId.toArray();  //data1的第i个引用文献的所有fid
                //Object[] data2_F = data2.FId.toArray(); //data2的所有fid
                for(int j = 0; j < data_t1_F.length; j++){
                    for(int k = 0; k < data2_F.length; k++){
                        if(Long.valueOf(String.valueOf(data_t1_F[j])).longValue() == Long.valueOf(String.valueOf(data2_F[k])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = Long.valueOf(String.valueOf(data_t1_F[j])).longValue();
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("RId-FId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
                //边为 Id-CId
                Object[] data_t1_C = data_t1.CId.toArray();  //data1的第i个引用文献的所有fid
                //Object[] data2_C = data2.CId.toArray(); //data2的所有fid
                for(int j = 0; j < data_t1_C.length; j++){
                    for(int k = 0; k < data2_C.length; k++){
                        if(Long.valueOf(String.valueOf(data_t1_C[j])).longValue() == Long.valueOf(String.valueOf(data2_C[k])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = Long.valueOf(String.valueOf(data_t1_C[j])).longValue();
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("RId-CId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
                //边为 Id-JId
                Object[] data_t1_J = data_t1.JId.toArray();  //data1的第i个引用文献的所有fid
                //Object[] data2_J = data2.JId.toArray(); //data2的所有fid
                for(int j = 0; j < data_t1_J.length; j++){
                    for(int k = 0; k < data2_J.length; k++){
                        if(Long.valueOf(String.valueOf(data_t1_J[j])).longValue() == Long.valueOf(String.valueOf(data2_J[k])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = Long.valueOf(String.valueOf(data_t1_J[j])).longValue();
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("RId-JId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
                //边为 Id-AuId
                Object[] data_t1_Au = data_t1.AuId.toArray();  //data1的第i个引用文献的所有fid
                //Object[] data2_Au = data2.AuId.toArray(); //data2的所有fid
                for(int j = 0; j < data_t1_Au.length; j++){
                    for(int k = 0; k < data2_Au.length; k++){
                        if(Long.valueOf(String.valueOf(data_t1_Au[j])).longValue() == Long.valueOf(String.valueOf(data2_Au[k])).longValue()){
                            long[] hop_3 = new long[4];
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = Long.valueOf(String.valueOf(data_t1_Au[j])).longValue();
                            hop_3[3] = data2.Id.get(0);
                            System.out.print("RId-AuId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }
                }
            }

        }

        return result;
    }

    //type: Id-AuID
    public static JSONArray getHop(Data data1, List<Data> data2_list, long Id2){
        Request request = new Request();
        JSONArray result=new JSONArray();
        //long[] hop_1 = {-1,-1};
        //long[] hop_2 = {-1,-1,-1};
        //long[] hop_3 = {-1,-1,-1,-1};

        //获取1跳数据
        for(int i = 0; i < data1.AuId.size(); i++){
            if(data1.AuId.get(i) == Id2){
                long[] hop_1 = new long[2];
                hop_1[0] = data1.Id.get(0);
                hop_1[1] = Id2;
                System.out.print(hop_1[0]+","+ hop_1[1]+"\n");
                result.add(hop_1);
                break;
            }
        }

        //获取2跳数据
        Object[] data1_R=data1.RId.toArray(); //data1的引用文献的Id的集合
        for(int i = 0; i < data1_R.length; i++){
            //这里速度比较慢……
            Data data_t1 = request.request(Long.valueOf(String.valueOf(data1_R[i])).longValue(),"Id");
            for(int j = 0; j<data_t1.AuId.size(); j++){
                if(data_t1.AuId.get(j) == Id2){
                    long[] hop_2 = new long[3];
                    hop_2[0] = data1.Id.get(0);
                    hop_2[1] = data_t1.Id.get(0);
                    hop_2[2] = Id2;
                    System.out.print("2-hop: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
            //获取3跳数据
            for(int j = 0; j < data_t1.RId.size(); j++){
                for(int k =0; k < data2_list.size(); k++){
                    if((long)data_t1.RId.get(j) == (long)data2_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = data_t1.Id.get(0);
                        hop_3[2] = data_t1.RId.get(j);
                        hop_3[3] = Id2;
                        System.out.print("RId-RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
                    /*
                    //下面为遍历方法，速度超级无敌慢慢慢，因为增加了api的请求的次数
                    data_t2 = request.request(data_t1.RId.get(j),"Id");
                    for(int k = 0; k < data_t2.AuId.size(); k++){
                        if(data_t2.AuId.get(k) == Id2){
                            hop_3[0] = data1.Id.get(0);
                            hop_3[1] = data_t1.Id.get(0);
                            hop_3[2] = data_t2.Id.get(0);
                            hop_3[3] = Id2;
                            System.out.print("RId-RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                            result.add(hop_3);
                            break;
                        }
                    }*/
            }

        }

        //获取3跳数据
        Object[] data1_Au = data1.AuId.toArray();
        for(int i = 0; i < data1_Au.length; i++){
            //data_t1 = request.request(Long.valueOf(String.valueOf(data1_Au[i])).longValue(),"Id");
            List<Data> data_t1_list = request.request(Long.valueOf(String.valueOf(data1_Au[i])).longValue(),"AA.AuId",1); //与data1有相同list的Id的集合
            for(int j = 0; j < data_t1_list.size(); j++){ //判断两个数组是否有交集
                //Au-AF
                for(int k = 0; k < data_t1_list.get(j).AfId.size(); k++){
                    if(data_t1_list.get(j).AfId.get(k) == null){ continue;} //处理AfId出现Null异常
                    for(int l = 0; l < data2_list.size(); l++){
                        for(int m = 0; m < data2_list.get(l).AfId.size(); m++){
                            if(data2_list.get(l).AfId.get(m) != null && (long)data2_list.get(l).AfId.get(m) == (long)data_t1_list.get(j).AfId.get(k)){
                                long[] hop_3 = new long[4];
                                hop_3[0] = data1.Id.get(0);
                                hop_3[1] = Long.valueOf(String.valueOf(data1_Au[i])).longValue();
                                hop_3[2] = data_t1_list.get(j).AfId.get(k);
                                hop_3[3] = Id2;
                                System.out.print("Au-Af: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                                result.add(hop_3);
                                break;
                            }
                        }
                    }
                }
                //Au_Id
                for(int k = 0; k < data2_list.size(); k++){
                    if((long)data_t1_list.get(j).Id.get(0) == (long)data2_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = Long.valueOf(String.valueOf(data1_Au[i])).longValue();
                        hop_3[2] = data_t1_list.get(j).Id.get(0);
                        hop_3[3] = Id2;
                        System.out.print("Au-Id: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }

        }
        //F_Id
        Object[] data1_F = data1.FId.toArray();
        for(int i = 0; i < data1_F.length; i++){
            //直接查询FId可能会返回很多数据，会导致运算变慢
            List<Data> data_t1_list = request.request(Long.valueOf(String.valueOf(data1_F[i])).longValue(),"F.FId",1); //获取和data1相同的FId的Id
            for(int j = 0; j < data_t1_list.size(); j++){
                for(int k = 0; k < data2_list.size(); k++){
                    if((long)data_t1_list.get(j).Id.get(0) == (long)data2_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = Long.valueOf(String.valueOf(data1_F[i])).longValue();
                        hop_3[2] = data_t1_list.get(j).Id.get(0);
                        hop_3[3] = Id2;
                        System.out.print("F-Id: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }
        //C_Id
        Object[] data1_C = data1.CId.toArray();
        for(int i = 0; i < data1_C.length; i++){
            //直接查询CId可能会返回很多数据，会导致运算变慢
            List<Data> data_t1_list = request.request(Long.valueOf(String.valueOf(data1_C[i])).longValue(),"C.CId",1); //获取和data1相同的CId的Id
            for(int j = 0; j < data_t1_list.size(); j++){
                for(int k = 0; k < data2_list.size(); k++){
                    if((long)data_t1_list.get(j).Id.get(0) == (long)data2_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = Long.valueOf(String.valueOf(data1_C[i])).longValue();
                        hop_3[2] = data_t1_list.get(j).Id.get(0);
                        hop_3[3] = Id2;
                        System.out.print("C-Id: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }
        //J_Id
        Object[] data1_J = data1.JId.toArray();
        for(int i = 0; i < data1_J.length; i++){
            //直接查询CId可能会返回很多数据，会导致运算变慢
            List<Data> data_t1_list = request.request(Long.valueOf(String.valueOf(data1_J[i])).longValue(),"J.JId",1); //获取和data1相同的CId的Id
            for(int j = 0; j < data_t1_list.size(); j++){
                for(int k = 0; k < data2_list.size(); k++){
                    if((long)data_t1_list.get(j).Id.get(0) == (long)data2_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = data1.Id.get(0);
                        hop_3[1] = Long.valueOf(String.valueOf(data1_J[i])).longValue();
                        hop_3[2] = data_t1_list.get(j).Id.get(0);
                        hop_3[3] = Id2;
                        System.out.print("J-Id: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }


        return result;
    }


    //type: AuId-Id
    public static JSONArray getHop(List<Data> data1_list, Data data2, long Id1){
        Request request = new Request();
        JSONArray result=new JSONArray();
        //long[] hop_1 = {-1,-1};
        //long[] hop_2 = {-1,-1,-1};
        //long[] hop_3 = {-1,-1,-1,-1};

        //获得一跳数据
        for(int i = 0; i<data1_list.size();i++){
            if((long)data1_list.get(i).Id.get(0) == data2.Id.get(0)){
                long[] hop_1 = new long[2];
                hop_1[0] = Id1;
                hop_1[1] = data2.Id.get(0);
                result.add(hop_1);
                System.out.print(hop_1[0]+","+ hop_1[1]+"\n");
                break;
            }
        }

        //获得两跳数据
        for(int i = 0; i < data1_list.size(); i++){
            for(int j = 0; j < data1_list.get(i).RId.size(); j++){
                if((long)data1_list.get(i).RId.get(j) == (long)data2.Id.get(0)){
                    long[] hop_2 = new long[3];
                    hop_2[0] = Id1;
                    hop_2[1] = data1_list.get(i).Id.get(0);
                    hop_2[2] = data2.Id.get(0);
                    System.out.print("2-hop: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }


        //获得3跳数据
        //////////////////////////////
        //Af_Au
        /*for(int i = 0; i < data1.size(); i++){
            for(int j = 0; j<data1.get(i).AfId.size(); j++){
                for(int k = 0; k < data2)
            }
        }*/

        //Id_Id
        List<Data> data2_R_list = request.request(data2.Id.get(0),"RId",1);
        for(int i = 0; i < data1_list.size(); i++){
            //下面运行速度较慢，还要再注释回来
            /*for(int j = 0; j < data1.get(i).RId.size(); j++){
                for(int k =0; k < data2_R_list.size(); k++){
                    if((long)data1.get(i).RId.get(j) == (long)data2_R_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1.get(i).Id.get(0);
                        hop_3[2] = data1.get(i).RId.get(j);
                        hop_3[3] = Id2;
                        System.out.print("RId: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }*/
            //Id_AuId,这里若条件允许，还要加上判断，hop_3[1] ！= hop_3[3]
            for(int j =0; j < data1_list.get(i).AuId.size(); j++){
                for(int k =0; k < data2.AuId.size(); k++){
                    if((long)data2.AuId.get(k) == (long)data1_list.get(i).AuId.get(j)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1_list.get(i).Id.get(0);
                        hop_3[2] = data2.AuId.get(k);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id_Au: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //Id_FId，这里若条件允许，还要加上判断，hop_3[1] ！= hop_3[3]
            for(int k = 0; k < data2.FId.size(); k++){
                for(int j = 0; j < data1_list.get(i).FId.size(); j++){
                    if((long)data2.FId.get(k) == (long)data1_list.get(i).FId.get(j)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1_list.get(i).Id.get(0);
                        hop_3[2] = data2.FId.get(k);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id_F: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            /*for(int j =0; j < data1_list.get(i).FId.size(); j++){
                for(int k =0; k < data2.FId.size(); k++){
                    if((long)data2.FId.get(k) == (long)data1_list.get(i).FId.get(j)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1_list.get(i).Id.get(0);
                        hop_3[2] = data2.FId.get(k);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id_F: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }*/
            //Id_CId，这里若条件允许，还要加上判断，hop_3[1] ！= hop_3[3]
            for(int j =0; j < data1_list.get(i).CId.size(); j++){
                for(int k =0; k < data2.CId.size(); k++){
                    if((long)data2.CId.get(k) == (long)data1_list.get(i).CId.get(j)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1_list.get(i).Id.get(0);
                        hop_3[2] = data2.CId.get(k);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id_C: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //Id_JId，这里若条件允许，还要加上判断，hop_3[1] ！= hop_3[3]
            for(int j =0; j < data1_list.get(i).JId.size(); j++){
                for(int k =0; k < data2.JId.size(); k++){
                    if((long)data2.JId.get(k) == (long)data1_list.get(i).JId.get(j)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1_list.get(i).Id.get(0);
                        hop_3[2] = data2.JId.get(k);
                        hop_3[3] = data2.Id.get(0);
                        System.out.print("Id_J: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
            //
        }

        ////////////////////////////
        return result;
    }

    //type: AuId-AuId
    public static JSONArray getHop(List<Data> data1_list, List<Data> data2_list,long Id1, long Id2){
        Request request = new Request();
        JSONArray result=new JSONArray();
        //long[] hop_2 = {-1,-1,-1};
        //long[] hop_3 = {-1,-1,-1,-1};
        //获取2跳数据
        for(int i = 0; i < data1_list.size(); i++){
            for(int j = 0; j < data2_list.size(); j++){
                if((long)data1_list.get(i).Id.get(0) == (long)data2_list.get(j).Id.get(0)){
                    long[] hop_2 = new long[3];
                    hop_2[0] = Id1;
                    hop_2[1] = data1_list.get(i).Id.get(0);
                    hop_2[2] = Id2;
                    System.out.print("Au-Au: "+hop_2[0]+","+ hop_2[1]+","+ hop_2[2]+"\n");
                    result.add(hop_2);
                    break;
                }
            }
        }
        //获取3跳数据
        for(int i = 0; i < data1_list.size(); i++){
            for(int j = 0; j < data1_list.get(i).RId.size(); j++){
                for(int k =0; k < data2_list.size(); k++){
                    if((long)data1_list.get(i).RId.get(j) == (long)data2_list.get(k).Id.get(0)){
                        long[] hop_3 = new long[4];
                        hop_3[0] = Id1;
                        hop_3[1] = data1_list.get(i).Id.get(0);
                        hop_3[2] = data1_list.get(i).RId.get(j);
                        hop_3[3] = Id2;
                        System.out.print("Id_Id: "+hop_3[0]+","+ hop_3[1]+","+ hop_3[2]+","+ hop_3[3]+"\n");
                        result.add(hop_3);
                        break;
                    }
                }
            }
        }

        return result;
    }
}
